package ast;

import java.io.PrintStream;
import java.util.Scanner;
import java.util.Map;
import java.util.Stack;

public class ReadIntExpr extends Expr {
    public ReadIntExpr(Location loc) {
        super(loc);
    }

    public void print(PrintStream ps) {
        ps.print("readint");
    }
    // interpret: prompt the user for a integer and return it, if does not get desired input, throws an FailedStdinReadException
    public AbstractValue evaluate(Stack<Map<String, AbstractValue>> state, Scanner scanner) throws Exception {
        return AbstractValue.AnyInt;
        /**
        // init a int
        long i = 0;
        // try to read a int from stdin
        try {
            if (scanner.hasNextLong()) {
                i = scanner.nextLong();
                return i;
            } else {
                throw new exceptions.FailedStdinReadException("Failed to read an integer from stdin");
            }
        } catch (Exception e) {
            throw new exceptions.FailedStdinReadException("Failed to read an integer from stdin");
        }
        */
    }
}
